package com.ruoyi.web.controller.tourism;

import java.util.List;

import com.ruoyi.system.domain.RoomType;
import com.ruoyi.system.service.IRoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;


@RestController
@RequestMapping("/hotels/roomType")
public class RoomTypeController extends BaseController
{
    @Autowired
    private IRoomTypeService roomTypeService;

    @GetMapping("/list/{hotelId}")
    public AjaxResult listRoomType(@PathVariable Long hotelId){
        List<RoomType> list = roomTypeService.getRoomTypeAndRooms(hotelId);
        return AjaxResult.success(list);
    }

    @PostMapping("/add")
    public AjaxResult addRoomType(@RequestBody RoomType roomType){
        roomTypeService.addRoomType(roomType);
        return AjaxResult.success();
    }

    @PutMapping("/update")
    public AjaxResult updateRoomType(@RequestBody RoomType roomType){
        roomTypeService.updateRoomType(roomType);
        return AjaxResult.success();
    }

    @GetMapping("{id}")
    public AjaxResult getRoomTypeById(@PathVariable Long id){
        RoomType roomType = roomTypeService.getRoomTypeById(id);
        return AjaxResult.success(roomType);
    }

    @DeleteMapping("/{id}")
    public AjaxResult deleteRoomType(@PathVariable Long id){
        roomTypeService.deleteRoomType(id);
        return AjaxResult.success();
    }
}
